package com.wealth.cart.entity;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import com.wealth.member.entity.Member;
import com.wealth.merchant.entity.Market;

/**
 * 
 * @author zjw
 */
@Entity
@Table(name="t_cart")
public class Cart implements Serializable{

	private static final long serialVersionUID = 1L;
	
	private Long id;
	private String ip;
	private Double total;
	private Integer amount;
	private Date createtime; 
	private List<CartItem> cartItems;
	private Member member;

	private Market market;
 
	
	/* ---------------- method ----------------*/
	
	

	public Cart() {}
	
	public Cart(Long id){
		this.id = id;
	}

	/* ---------------- getter/setter ----------------*/
	
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	
	@Column(name = "ip")
	public String getIp() {
		return ip;
	}

	public void setIp(String ip) {
		this.ip = ip;
	}
	
	@ManyToOne
	@JoinColumn(name="merchant_market_id")
	public Market getMarket() {
		return market;
	}

	public void setMarket(Market market) {
		this.market = market;
	}
	
	@Column(name="create_time")
	public Date getCreatetime() {
		return createtime;
	}

	public void setCreatetime(Date createtime) {
		this.createtime = createtime;
	}
	
	 
	@Column(name = "total")
	public Double getTotal() {
		return total;
	}

	public void setTotal(Double total) {
		this.total = total;
	}

	@Column(name = "amount")
	public Integer getAmount() {
		return amount;
	}

	public void setAmount(Integer amount) {
		this.amount = amount;
	}

	
	@OneToMany(mappedBy="cart")
	public List<CartItem> getCartItems() {
		return cartItems;
	}

	public void setCartItems(List<CartItem> cartItems) {
		this.cartItems = cartItems;
	}

	@ManyToOne 
    @JoinColumn(name="memberid")
	public Member getMember() {
		return member;
	}

	public void setMember(Member member) {
		this.member = member;
	}
	
	 
}


